<?php
/**
 * @author Feng
 * @date 2012-6-16
 */
class collection_site_row extends collection_rule_row {
	
	public function setName($name) {
		if(!$name) {
			$this->set('name', '');
		} else {
			$name = preg_replace('/[^\w]+/is', '-', $name);
			$this->set('name', $name);
		}
		return $this;
	}
	
	/**
	 * @return collection_collect_abstract
	 */
	public function getItemRule() {
		if(!($iid = intval($this->getItemRuleId()))) {
			return new collection_collect_item(null);
		}
		$concept = new collection_rule_concept();
		return new collection_collect_item($concept->fetch(array('id = ?' => $iid)));
	}
	
	/**
	 * @return collection_collect_abstract
	 */
	public function getSpecialRule() {
		if(!($iid = intval($this->getSpecialRuleId()))) {
			return new collection_collect_item(null);
		}
		$concept = new collection_rule_concept();
		return new collection_collect_item($concept->fetch(array('id = ?' => $iid)));
	}
	
}
